#博客详情测试
from selenium.webdriver.common.by import By
from common.Utils import BlogDriver
import time

class BlogDetail:
    url = ""
    driver = ""
    def __init__(self):
        self.url = "http://8.137.19.140:9090/blog_detail.html?blogId=99339"
        self.driver = BlogDriver.driver
        self.driver.get(self.url)

#登录状态下
    def DetailTestByLogin(self):
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div > div.title") #检查标题
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div > div.date") #检查时间
        self.driver.find_element(By.CSS_SELECTOR, "#detail > p") #检查内容
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div > div.operating > button:nth-child(1)") #检查编辑按钮
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div > div.operating > button:nth-child(2)") #检查删除按钮

        BlogDriver.getScreeShot()
#未登录状态下
    def DetailTestNoLogin(self):
        #可以点击注销按钮回到登录页面，然后直接访问list文件，此时会强制回到登录页面，再判断登录页面的内容即可
        self.driver.find_element(By.CSS_SELECTOR,"body > div.nav > a:nth-child(6)").click()
        time.sleep(1)
        self.driver.get(self.url)
        text = self.driver.find_element(By.CSS_SELECTOR, "body > div.container-login > div > h3").text
        print(text)
        assert text == "登陆"

